package com.xplusplus.security.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.util.Date;
import java.util.Set;

/**
 * @Author: zhouweixin
 * @Description: 临时项目表头
 * @Date: Created in 14:28 2018/9/3
 * @Modified By:
 */
@Entity
@ApiModel(value = "临时项目表头")
public class TemporaryProjectHeader {
    @Id
    @ApiModelProperty(value = "主键：自增长")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Temporal(value = TemporalType.DATE)
    @JsonFormat(pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @ApiModelProperty(value = "日期, 格式为yyyy-MM-dd")
    private Date date;

    @Temporal(value = TemporalType.TIMESTAMP)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "申请时间, 格式为yyyy-MM-dd HH:mm:ss")
    private Date applyTime;

    @Temporal(value = TemporalType.TIMESTAMP)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "审核时间, 格式为yyyy-MM-dd HH:mm:ss")
    private Date auditTime;

    @ApiModelProperty(value = "人数")
    private Integer personNum = 0;

    @ApiModelProperty(value = "总支出")
    private Double totalWage = 0.0;

    @ApiModelProperty(value = "服务费")
    private Double serviceCharge = 0.0;

    @ApiModelProperty(value = "内容")
    private String content;

    @ManyToOne(targetEntity = User.class)
    @JoinColumn(name = "applicant_id", referencedColumnName = "id")
    @ApiModelProperty(value = "申请人")
    private User applicant;

    @ManyToOne(targetEntity = User.class)
    @JoinColumn(name = "operator_id", referencedColumnName = "id")
    @ApiModelProperty(value = "经办人")
    private User operator;

    @ManyToOne(targetEntity = User.class)
    @JoinColumn(name = "auditor_id", referencedColumnName = "id")
    @ApiModelProperty(value = "审核人")
    private User auditor;

    @ApiModelProperty(value = "审核状态：0未审核；1同意；2不同意")
    private Integer status = 0;

    @ApiModelProperty(value = "审核意见")
    private String note = "";

    @ManyToOne(targetEntity = Department.class)
    @JoinColumn(name = "department_id", referencedColumnName = "id")
    @ApiModelProperty(value = "出勤部门")
    private Department department;

    @OneToMany(targetEntity = TemporaryProjectDetail.class, cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    @JoinColumn(name = "header_id")
    private Set<TemporaryProjectDetail> details;

    public TemporaryProjectHeader() {
        this.applyTime = new Date();
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public Integer getPersonNum() {
        return personNum;
    }

    public void setPersonNum(Integer personNum) {
        this.personNum = personNum;
    }

    public Double getTotalWage() {
        return totalWage;
    }

    public void setTotalWage(Double totalWage) {
        this.totalWage = totalWage;
    }

    public Double getServiceCharge() {
        return serviceCharge;
    }

    public void setServiceCharge(Double serviceCharge) {
        this.serviceCharge = serviceCharge;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public User getApplicant() {
        return applicant;
    }

    public void setApplicant(User applicant) {
        this.applicant = applicant;
    }

    public User getOperator() {
        return operator;
    }

    public void setOperator(User operator) {
        this.operator = operator;
    }

    public Department getDepartment() {
        return department;
    }

    public void setDepartment(Department department) {
        this.department = department;
    }

    public Set<TemporaryProjectDetail> getDetails() {
        return details;
    }

    public void setDetails(Set<TemporaryProjectDetail> details) {
        this.details = details;
    }

    public User getAuditor() {
        return auditor;
    }

    public void setAuditor(User auditor) {
        this.auditor = auditor;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    public Date getApplyTime() {
        return applyTime;
    }

    public void setApplyTime(Date applyTime) {
        this.applyTime = applyTime;
    }

    public Date getAuditTime() {
        return auditTime;
    }

    public void setAuditTime(Date auditTime) {
        this.auditTime = auditTime;
    }
}
